package com.sheepone.distributor.thread;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadFactory;

/**
 * @author Miss.杨
 * @description
 * @since 2023-12-08 18:13
 */
public enum NamedThreadFactoryManager {
    INSTANCE;

    private final ConcurrentHashMap<String, ThreadFactory> namedThreadFactories = new ConcurrentHashMap<>();

    public ThreadFactory acquire(String name) {
        return namedThreadFactories.computeIfAbsent(name, NamedDaemonThreadFactory::new);
    }
}
